/**
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 *
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 */
package com.acp.controller;

import com.acp.model.UploadFile;
import com.acp.result.JsonData;
import com.acp.result.PageResult;
import com.acp.service.UploadFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version V1.0
 * @Title: UploadFileController
 * @Package
 * @Description: 文件上传管理
 * @author: 张逍
 * @date: Created in 2019/7/25 8:57 PM
 */
@RestController
@RequestMapping("/uploadFile")
@Api(value="文件上传记录", description = "文件上传记录")
public class UploadFileController {

    @Resource
    private UploadFileService uploadFileService;



    /**
     * @Description 条件查询文件列表,分页
     * @Author 张逍
     * @Date 2019/5/11
     * @param record 日志信息实体
     * @return com.dci.result.PageResult
     */
    @ApiOperation(value = "查询文件列表", notes = "条件查询文件列表,分页", httpMethod = "POST", response = PageResult.class)
    @ApiImplicitParam(name = "record", value = "文件上传实体UploadFile", dataType = "UploadFile")
    @PostMapping("/fileList")
    public PageResult selectUploadFileList(@RequestBody UploadFile record) {
        try {
            return uploadFileService.selectFileList(record);
        } catch (Exception e) {
            e.printStackTrace();
            return PageResult.fail(911);
        }
    }


    /**
     * @Description 删除文件上传记录, 同时删除文件
     * @Author 张逍
     * @Date 2019/7/26
     * @param list
     * @return com.acp.result.JsonData
     */
    @ApiOperation(value = "删除文件上传记录", notes = "删除文件上传记录", httpMethod = "POST", response = PageResult.class)
    @ApiImplicitParam(name = "list", value = "List", dataType = "List")
    @PostMapping("/delete")
    public JsonData delete(@RequestBody List<UploadFile> list) {
        try {
            return uploadFileService.delete(list);
        } catch (Exception e) {
            return JsonData.fail(911);
        }
    }


}
